
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/changeOrder.do"/>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.sales.LineItem,
                 com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.sales.forms.SplitSalesOrderForm,com.scalar.chiptrack.utils.StringUtils,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.users.Functionality"%>
<%@ page import="java.util.ArrayList" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();
  int i = 0;
%>

<HTML><HEAD><TITLE>Scalarsoft - Chip Trac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR>

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>

<SCRIPT language="JavaScript">


function submitPage(value)
{
    var pa =document.getElementById("message");

    if(value=='SUBMIT')
    {

        var tempQtyToSplit = document.splitSalesOrderForm["qtyToSplit"];
        var tempQty = document.splitSalesOrderForm["quantity"];
        var tempShippedQty = document.splitSalesOrderForm["shippedQty"];

        var tempVal=false;

        if(document.splitSalesOrderForm.lineItemId.length == null)
        {
              if(document.splitSalesOrderForm.split0.checked == false)
              {
                pa.innerHTML = '<li>'+'Please select atleast one Line Item to split and enter the Split Quantity';
                return;
              }
        }
        else
        {

            for(var i=0; i< tempQtyToSplit.length; i++)
            {
              var tempSplit = document.getElementById("split"+i);

              if(tempSplit.checked == true)
              {
                tempVal = true;
                break;
              }
            }
            if(tempVal == false)
            {
                pa.innerHTML = '<li>'+'Please select atleast one Line Item to split and enter the Split Quantity';
                return;
            }
        }

        if(document.splitSalesOrderForm.lineItemId.length == null)
        {
                    var tempSplit = document.splitSalesOrderForm.split0;
                    var tempQtyToSplit = document.splitSalesOrderForm.qtyToSplit;
                    var tempQty = document.splitSalesOrderForm.quantity;
                    var tempShippedQty = document.splitSalesOrderForm.shippedQty;

                    if(tempSplit.checked==true)
                    {
                        if( checkInteger(tempQtyToSplit.value.trim(),"Split Quantity","Y") == false)
                        {
                            errors = errMsg;
                            tempQtyToSplit.select();
                            tempQtyToSplit.focus();
                            pa.innerHTML = '<li>'+errors;
                            return;
                        }
                        <!--    Modified by veeru on (03/08/04) add '=' and commented if block       -->
                        if(tempQtyToSplit.value >= (tempQty.value - tempShippedQty.value))
                        {
                            //alert(tempQty.value - tempShippedQty.value);
                            pa.innerHTML = '<li>'+'Please enter Split Quantity lesser than Remaining Quantity '+(tempQty.value - tempShippedQty.value)
                            tempQtyToSplit.select();
                            tempQtyToSplit.focus();
                            return;
                        }
                        /* if((tempShippedQty.value==0) && (tempQtyToSplit.value == tempQty.value))
                        {
                            pa.innerHTML = '<li>'+'Please enter Split Quantity lesser than Quantity available '+(tempQty.value)+' to split'
                            tempQtyToSplit.select();
                            tempQtyToSplit.focus();
                            return;
                        } */
                        if(tempQtyToSplit.value==0)
                        {
                            pa.innerHTML = '<li>'+'Split Quantity cannot be zero '
                            tempQtyToSplit.select();
                            tempQtyToSplit.focus();
                            return;
                        }
                    }
        }
        else
        {
            for(var i=0; i< tempQtyToSplit.length; i++)
            {
                    var tempSplit = document.getElementById("split"+i);
                    if(tempSplit.checked==true)
                    {
                        if( checkInteger(tempQtyToSplit[i].value.trim(),"Split Quantity","Y") == false)
                        {
                            errors = errMsg;
                            tempQtyToSplit[i].select();
                            tempQtyToSplit[i].focus();
                            pa.innerHTML = '<li>'+errors;
                            return;
                        }
                        <!--    Modified by veeru on (03/08/04) add '=' and commented if block       -->
                        if(tempQtyToSplit[i].value >= (tempQty[i].value - tempShippedQty[i].value))
                        {
                            //alert(tempQty[i].value - tempShippedQty[i].value);
                            pa.innerHTML = '<li>'+'Please enter Split Quantity lesser than Remaining Quantity '+(tempQty[i].value - tempShippedQty[i].value)
                            tempQtyToSplit[i].select();
                            tempQtyToSplit[i].focus();
                            return;
                        }
                        /* if((tempShippedQty[i].value==0) && (tempQtyToSplit[i].value == tempQty[i].value))
                        {
                            pa.innerHTML = '<li>'+'Please enter Split Quantity lesser than Quantity available '+(tempQty[i].value)+' to split'
                            tempQtyToSplit[i].select();
                            tempQtyToSplit[i].focus();
                            return;
                        } */

                        if(tempQtyToSplit[i].value==0)
                        {
                            pa.innerHTML = '<li>'+'Split Quantity cannot be zero '
                            tempQtyToSplit[i].select();
                            tempQtyToSplit[i].focus();
                            return;
                        }
                    }
            }
       }
        if(document.splitSalesOrderForm.lineItemId.length == null)
        {
            document.splitSalesOrderForm.qtyToSplit.disabled = false;
        }
        else
        {
            for(var i=0; i< tempQtyToSplit.length; i++)
            {
               tempQtyToSplit[i].disabled = false;
            }
        }
        document.splitSalesOrderForm.action = "splitSalesOrder.do?action=splitSalesOrder&customerId="+document.splitSalesOrderForm.customerId.value+"&isSample="+document.splitSalesOrderForm.isSample.value;
    }
    else if(value=='CONFIRM')
    {
        document.splitSalesOrderForm.action = "splitSalesOrder.do?action=confirmSplitSalesOrder&customerId="+document.splitSalesOrderForm.customerId.value+"&isSample="+document.splitSalesOrderForm.isSample.value;
    }
    else if(value=='CONFIRM_REQUEST_FROM_PENDING_ORDERS')
    {
        // Added by Murali Krishna yengala on January 11 2005, this condition is evaluated, if the "split line items" is reached from pending orders
        document.splitSalesOrderForm.action = "splitSalesOrder.do?frmPending=1&action=confirmSplitSalesOrder&isSample="+document.splitSalesOrderForm.isSample.value;
    }
    else if ( value == 'CANCEL' )
    {
        document.splitSalesOrderForm.action="changeOrder.do?action=EditChangeOrder";
    }
    else if ( value == 'CANCEL_TO_PENDING')
    {
        document.splitSalesOrderForm.action="approveOrder.do";
    }
    document.splitSalesOrderForm.submit();
}

function enableQtyToSplit(flag)
{
    var tempQtyToSplit;
    if(document.splitSalesOrderForm.lineItemId.length == null)
    {
        var tempSplit = document.splitSalesOrderForm.split0;
        tempQtyToSplit = document.splitSalesOrderForm.qtyToSplit;
        if(tempSplit.checked == true)
        {
            tempQtyToSplit.disabled = false;
            tempQtyToSplit.focus();
        }
        else
        {
            tempQtyToSplit.disabled = true;
            tempQtyToSplit.value = "";

        }
    }
    else
    {
        var tempSplit = document.getElementById("split"+flag);
        tempQtyToSplit = document.splitSalesOrderForm["qtyToSplit"];

        if(tempSplit.checked == true)
        {
            tempQtyToSplit[flag].disabled = false;
            tempQtyToSplit[flag].focus();
        }
        else
        {
            tempQtyToSplit[flag].disabled = true;
            tempQtyToSplit[flag].value = "";

        }
    }
}

function resetValues()
{
    if(document.splitSalesOrderForm.lineItemId.length == null)
    {
        var tempSplitChkBox = document.splitSalesOrderForm.split0;

        document.splitSalesOrderForm.qtyToSplit.value = "";
        document.splitSalesOrderForm.qtyToSplit.disabled = true;
        tempSplitChkBox.checked=false;

    }
    else
    {
        var tempQtyToSplit = document.splitSalesOrderForm["qtyToSplit"];
        for(var i=0; i< tempQtyToSplit.length; i++)
        {
            var tempSplitChkBox = document.getElementById("split"+i);
            tempQtyToSplit[i].value = "";
            tempQtyToSplit[i].disabled = true;
            tempSplitChkBox.checked=false;

        }
    }

}


// Added by Gandhi on 25 Nov 2004 to enable split quantity field(s) while click on Edit button.

function setEnable(flag)
{
        var tempQtyToSplit;
        if(document.splitSalesOrderForm.lineItemId != null && document.splitSalesOrderForm.lineItemId.length == null)

        {
            var tempSplit = document.splitSalesOrderForm.split0;
            tempQtyToSplit = document.splitSalesOrderForm.qtyToSplit;

                if(tempSplit.checked == true)
                {
                    tempQtyToSplit.disabled = false;
                    tempQtyToSplit.focus();
                }
        }

        else
        {
          tempQtyToSplit = document.splitSalesOrderForm["qtyToSplit"];
               for(var i=0; tempQtyToSplit!=null && i< tempQtyToSplit.length; i++)
               {
                        var tempSplit = document.getElementById("split"+i);
                        if( tempSplit.checked == true )
                        {
                            tempQtyToSplit[i].disabled = false;
                            tempQtyToSplit[i].focus();

                        }

               }

        }

}

// Ends here - Gandhi

var dateElement = "";
function openCalendar(dateValue)
{
    dateElement = dateValue;
    newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','calenderPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
    newWindow.moveTo(550,180);
    newWindow.focus();
}
function assignDate(passedValue)
{
    dateElement.value=passedValue;
    window.focus();
}
</SCRIPT>
</HEAD>

<%
    String action = request.getParameter( "action" );
    if( action != null && "splitSalesOrder".equals( action ) )
    {
%>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"  >
<%}else{%>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"  onLoad="javascript:setEnable(<%=i%>)">
<%}%>

<!-- Top Header Start-->
<% String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + ""; %>
<logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
    <%@ include file="/jsp/includes/header.jsp" %>
</logic:equal>
<logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
    <%@ include file="/jsp/includes/extHeader.jsp" %>
</logic:notEqual>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
    <TR>
	    <td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
        <!-- Side Navigation start -->
        <%
            String heading = "";
            if( ( request.getParameter( "isSample" ) != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) )
            {
                heading = "Sample Order";
        %>
	    <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sample_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sample_order_menu.jsp" %>
        </logic:notEqual>
        <%
            }
            else
            {
                heading = "Sales Order";
        %>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/sales_order_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/sales/ext_sales_order_menu.jsp" %>
        </logic:notEqual>
        <% } %>
        </TD>
        <!-- end of the side navigations -->
        <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">
            <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
            <BR>
            <html:html>
            <!-- from here your body starts -->
            <img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>
            <table border="0" width="95%" align=right>
                <tr>
                    <td colspan='7' align="left" class='NArialL'>
                        <html:form name="splitSalesOrderForm" action="/splitSalesOrder.do" method="post" type="com.scalar.chiptrack.sales.forms.SplitSalesOrderForm">
                        <html:hidden name="splitSalesOrderForm" property="customerId" />
                        <FONT id="error" styleClass="NArialL" color='FF0000'></FONT>
                    </TD>
                </TR>
                <tr><td colspan=6> <center><span class="NArialW">Split <%=heading%></span></center></td></tr>
                <tr><td height=20 colspan=6> </td></tr>
                <tr>
                    <td height=20 colspan=6>
                    <chiptrack:info styleClass="NArialL" />
                    <chiptrack:errors styleClass="NArialL" />
                    <chiptrack:messages type="info" styleClass="NArialL" />
                    </td>
                </tr>
               <tr><td colspan='6' align="left" class='NArialL'><FONT id="message" color='FF0000'></FONT><br></TD></tr>
                <tr><td colspan=6> <center><span class="NArialL"><%=heading%> #  <bean:write name="splitSalesOrderForm" property="salesOrderNo" /></span></center> </td></tr>
                <tr>
                    <td colspan=6>
                        <table border="0" width="98%" bordercolor="#FFFFFF">
	                        <tr>
	                            <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Line Item</font></font></td>
                                <td width="8%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">PO Line Item</font></font></td>
	                            <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.mfgPartNumber" /></font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.customerPartNumber"/></font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Description</font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Req'd Dock Date<br>(mm/dd/yyyy)</font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Schedule Date<br>(mm/dd/yyyy)</font></font></td>
                                <td width="5%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Quantity</font></font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Price </font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Amount</font></font></td>
                                <td width="100" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Shipped / PS Issued Quantity</font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Remaining Quantity</font></font></td>
                                <%
                                String salesOrderId = request.getParameter("salesOrderId");
                                if( "splitLineItems".equals( action ) )
                                {
                                    action = "";
                                }
                                if( salesOrderId != null )
                                {
                                    request.setAttribute( "salesOrderId", salesOrderId );
                                }
                                if( action == null )
                                {
                                    action = "";
                                }
                                if( "".equals( action ) || "confirmSplitSalesOrder".equals( action ) )
                                {
                                %>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Split</font></font></td>
                                <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Split Quantity</font></font></td>
                                <%
                                }
                                %>
                            </tr>
                                <%
                                ArrayList lineItems = null;
                                try
                                {
                                    lineItems = ( ArrayList ) request.getAttribute( "lineItems" );
                                }
                                catch( NullPointerException e ){ e.printStackTrace(); }
                                %>
                                <bean:define id="lineItemsTemp" name="lineItems" type="java.util.ArrayList"/>
                                <%
                                int lineItemsCount	= 0;
                                lineItemsCount = ( lineItemsTemp == null) ? 0 : lineItemsTemp.size();
                                if( "".equals( action ) || "confirmSplitSalesOrder".equals( action ) )
                                {
                                %>
                            <logic:iterate id="LineItem" name="lineItems" type="com.scalar.chiptrack.sales.LineItem">
                            <tr bgcolor="#DEE1E2">
                                <td class="NArialL"><%=LineItem.getLineItemNo()%></td>
                                <td class="NArialL"><%=LineItem.getPoLineItemNo()%></td>
                                <td nowrap class="NArialL"><%=LineItem.getManufacturingPartNo()%></td>
                                <td width="25%" class="NArialL"><%=LineItem.getCustomerPartNo()%></td>
                                <td width="25%" class="NArialL"><%=LineItem.getDescription()%></td>
                                <td align="center" class="NArialL"><%=LineItem.getRequestDate()%></td>
                                <td align="center" class="NArialL"><%=LineItem.getScheduleDate()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getQuantity()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getUnitPriceAsDouble()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getAmountAsString()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getShippedQty()%></td>
                                <bean:define id="qty" name="LineItem" property="quantity" />
                                <bean:define id="sqty" name="LineItem" property="shippedQty" />
                                <%
                                    int rQty = Integer.parseInt(qty.toString()) - Integer.parseInt(sqty.toString());
                                %>
                                <td align="right"><font class="NArialL"><%=rQty%></font></td>
                                <td align="center"><font class="NArialL"><input type="checkbox" name="split<%=i%>" value="on" onClick="javascript:enableQtyToSplit(<%=i%>);" ></font></td>
                                <td><font class="NArialL"><input type="text" name="qtyToSplit" size=9 class="valuetxfield" disabled="true"/></font></td>
                            </tr>
                            <tr>
                                <td colspan=12>
                                    <html:hidden name="LineItem" property="lineItemId" />
                                    <html:hidden name="LineItem" property="lineItemNo" />
                                    <html:hidden name="LineItem" property="quantity" />
                                    <html:hidden name="LineItem" property="shippedQty" />
                                    <html:hidden name="splitSalesOrderForm" property="salesOrderId" />
                                </td>
                            </tr>
                                <% i++; %>
                            </logic:iterate>
                            <%
			                if ( lineItemsCount == 0 )
			                {
	                        %>
                            <tr>
                                <td colspan="14"><font class="NArialL" style="color:red">&nbsp;&nbsp;No Line items available for Splitting</font></td>
                            </tr>
                            <%
                            }
                            }
                            %>
                            <% if( "splitSalesOrder".equals( action ) ) { %>
                            <logic:iterate id="LineItem" name="lineItemsAfterSplit" type="com.scalar.chiptrack.sales.LineItem">
                            <tr bgcolor="#DEE1E2">
                                <td class="NArialL"><%=LineItem.getLineItemNo()%></td>
                                <td class="NArialL"><%=LineItem.getPoLineItemNo()%></td>
                                <td nowrap class="NArialL"><%=LineItem.getManufacturingPartNo()%></td>
                                <td width="25%" class="NArialL"><%=LineItem.getCustomerPartNo()%></td>
                                <td width="25%" class="NArialL"><%=LineItem.getDescription()%></td>
                                <td align="center" class="NArialL"><%=LineItem.getRequestDate()%></td>
                                <td align="center" class="NArialL"><%=LineItem.getScheduleDate()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getQuantity()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getUnitPriceAsDouble()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getAmountAsString()%></td>
                                <td align="right" class="NArialL"><%=LineItem.getShippedQty()%></td>
                                <bean:define id="qty" name="LineItem" property="quantity" />
                                <bean:define id="sqty" name="LineItem" property="shippedQty" />
                                <%
                                int rQty = Integer.parseInt(qty.toString()) - Integer.parseInt(sqty.toString());
                                %>
                                <td align="right"><font class="NArialL"><%=rQty%></font></td>
                            </tr>
                            <% i++; %>
                            </logic:iterate>
                            <tr><td colspan=10><font color="red" class="NArialL">&nbsp;</font></td></tr>
                            <tr>
                                <td valign=top colspan=2 class="NArialL"><font color="red"><u>Warning:</u></font></td>
                                <td colspan=8 class="NArialL"><font color="red">Please note that if you confirm to split the line items, you can't merge it back to previous stage. So, please check before confirming.</font></td>
                            </tr>
                            <%
                            }
                            %>
                        </table>
                    </td>
                </tr>
                <tr><td colspan='6'  height="10" align="left"><FONT id="font1"></FONT></TD></TR>
                <tr>
                    <td colspan=6 align=center>
                <%
                    if(action!=null && "splitSalesOrder".equals(action))
                    {
                        /*  Added by Murali Krishna Yengala on January 11 2005
                            The following condition checks if the "split sales order" is reached from pending orders,
                            adds a request parameter "frmPending" if the request has come from pending orders
                        */
                        if( request.getAttribute("frmPending") != null)
                        {
                            if( ( request.getParameter("isSample") != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) )
                            {
                %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('CONFIRM_REQUEST_FROM_PENDING_ORDERS');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" border='0'></chiptrack:restrictedLink>
                <%           } else {    %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('CONFIRM_REQUEST_FROM_PENDING_ORDERS');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" border='0'></chiptrack:restrictedLink>
                <%           }

                        }
                        else
                        {
                            if( ( request.getParameter("isSample") != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) )
                            {
                %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('CONFIRM');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" border='0'></chiptrack:restrictedLink>
                <%           } else {    %>
                            <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('CONFIRM');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" border='0'></chiptrack:restrictedLink>
                <%           }

                        }
                %>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:history.back();"><img src='<%=chipTracContext%>/jsp/includes/images/edit.gif' border=0></a>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <%
                    }
                    else if ( lineItemsCount > 0 )
                    {
                        if( ( request.getParameter("isSample") != null ) && ( request.getParameter( "isSample" ).equals( "0" ) ) )
                        {
                %>
                        <chiptrack:restrictedLink functionality='<%=Functionality.SAMPLE_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('SUBMIT');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0'></chiptrack:restrictedLink>
                <%      } else {    %>
                        <chiptrack:restrictedLink functionality='<%=Functionality.SALES_CHANGE_ORDER%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:submitPage('SUBMIT');" onmouseover="window.status='Click here to save sales order';return true" onmouseout="window.status='';return true"><img src="<%=chipTracContext%>/jsp/includes/images/submit.gif" border='0'></chiptrack:restrictedLink>
                <%      }           %>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:resetValues();"><img src='<%=chipTracContext%>/jsp/includes/images/reset.gif' border=0></a>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <%
                    if( request.getAttribute("frmPending") != null)
                    {
                %>
                <a href="javascript:submitPage('CANCEL_TO_PENDING');"><img src='<%=chipTracContext%>/jsp/includes/images/cancel.gif' border=0></a>
                <% } else { %>
                <a href="javascript:submitPage('CANCEL');"><img src='<%=chipTracContext%>/jsp/includes/images/cancel.gif' border=0></a>
                <%
                    }
                    }
	                else
	                {
                    if( request.getAttribute("frmPending") != null)
                    {
                %>
				<a href="javascript:submitPage('CANCEL_TO_PENDING');">
					<img border="0" width="39" height="17" src="<%=chipTracContext%>/jsp/includes/images/back.gif"  onmouseover="window.status='Click to go back';return true" onmouseout="window.status='';return true" title="Click here to go back"  width="53" height="17">
				</a>
		        <%	} else { %>
				<a href="javascript:submitPage('CANCEL');">
					<img border="0" width="39" height="17" src="<%=chipTracContext%>/jsp/includes/images/back.gif"  onmouseover="window.status='Click to go back';return true" onmouseout="window.status='';return true" title="Click here to go back"  width="53" height="17">
				</a>
		        <%
			        }
                    }
	            %>
                    </td>
                </tr>
            </table>
            <input type="hidden" name="shipAccount1" value="<%=request.getParameter("shipAccount1")%>"/>
            <input type="hidden" name="isSample" value="<%=request.getParameter("isSample")%>">
            <%
            if( request.getAttribute("frmPending") != null )
            {
            %>
                <input type="hidden" name="frmPending" value="<%=request.getAttribute("frmPending")%>">
            <%
            }
            %>
                        </html:form>
            </html:html>
            <!-- till here -->
            <BR><BR><BR>
        </TD>
        <TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
